#include <sys/types.h>
#include <unistd.h>
#include <sys/stat.h>
#include <string.h>
#include <stdio.h>
#include <fcntl.h>

int main()
{
    if(mkfifo("./myfifo",0666) == -1)
    {
        perror("fifo fail");
    }
    char buffer[256] = {0};
    pid_t pid = fork();
    if(pid == 0)
    {
        int fd1 = open("./myfifo",O_WRONLY);
        strcpy(buffer,"i am process A");
        write(fd1,buffer,sizeof(buffer));
    }else
    {
        int fd2 = open("./myfifo",O_RDONLY);
        read(fd2,buffer,sizeof(buffer));
        printf("%s\n",buffer);
        unlink("./myfifo");
    }
    return 0;
}